/*
 * UsuariosForm.java
 *
 * Created on 3 de julio de 2008, 20:13
 */

package View;

import Controller.ABMUsuarioController;
import Model.Permiso;
import Model.Usuario;
import com.birosoft.liquid.LiquidLookAndFeel;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;

/**
 *
 * @author  Ernesto
 */
public class UsuariosForm extends javax.swing.JFrame {
        ABMUsuarioController abmuc;
        Vector v;
        Vector asignados;
        Usuario usuario;
        private PpalForm ppal;
        private String estado = "";
 
        /** Creates new form UsuariosForm */
    public UsuariosForm() {

                // Se carga el Look and Feel
        try {
            UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");   
        } catch (Exception e) { }
          LiquidLookAndFeel.setStipples(false);
          LiquidLookAndFeel.setShowTableGrids(true);
            
          initComponents();
             
           abmuc=new ABMUsuarioController();
           v=new Vector();
           asignados = new Vector();
          
          jComboUsuarios.setEnabled(false);
          estadoPanelUsuario(false);
          estadoPanelPermisos(false);
          jButtonAceptar.setEnabled(false);
          this.jButtonEliminar.setEnabled(false);
          this.jButtonGuardar.setVisible(false);
          jLabelSelecion.setVisible(false);
          jComboUsuarios.setVisible(false);
          jButtonEliminar.setVisible(false);
          
    }

    void setNuevaPass(String p1) {
         this.jTextPass.setText(p1);
         usuario.setPassword(p1);
         abmuc.cambiarPsw(usuario);
    

 }
    
    
    
    private void estadoPanelUsuario (boolean estado){
        jTextNombre.setEnabled(estado);
        jTextPass.setEnabled(estado);
        jTextNom.setEnabled(estado);
        jTextApe.setEnabled(estado);
        jTextNombre.setEditable(estado);
        jTextPass.setEditable(estado);
        jTextNom.setEditable(estado);
        jTextApe.setEditable(estado);
        
        
        jButtonGuardar.setEnabled(estado);
        jButtonEliminar.setEnabled(estado);
  }
            
    private void estadoPanelPermisos(boolean estado){
        jButtonDisponibleAsignado.setEnabled(estado);
        jButtonAsignadoDisponible.setEnabled(estado);
        this.jListAsignados.setEnabled(estado);
        this.jListDisponibles.setEnabled(estado);
        
    }
    
    
    
    
    
    /**cargo el combo con los usuarios disponible*/
    public void cargarComboUsuarios(){
        jComboUsuarios.removeAllItems();
        
        for (int i=0; i<abmuc.obtenerUsuarios().size();i++)
            jComboUsuarios.addItem(abmuc.obtenerUsuarios().get(i));
    }
    
    private void vaciarComboUsuarios(){
         jComboUsuarios.removeAllItems();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jListAsignados = new javax.swing.JList();
        jButtonDisponibleAsignado = new javax.swing.JButton();
        jListDisponibles = new javax.swing.JList();
        jLabel6 = new javax.swing.JLabel();
        jButtonAceptar = new javax.swing.JButton();
        jButtonAsignadoDisponible = new javax.swing.JButton();
        jButtonVolver = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jTextNombre = new javax.swing.JTextField();
        jLabelNombre = new javax.swing.JLabel();
        jLabelPass = new javax.swing.JLabel();
        jLabelNom = new javax.swing.JLabel();
        jLabelApe = new javax.swing.JLabel();
        jTextNom = new javax.swing.JTextField();
        jTextApe = new javax.swing.JTextField();
        jButtonGuardar = new javax.swing.JButton();
        jButtonEliminar = new javax.swing.JButton();
        jComboUsuarios = new javax.swing.JComboBox();
        jLabelSelecion = new javax.swing.JLabel();
        jTextPass = new javax.swing.JPasswordField();
        jPanel3 = new javax.swing.JPanel();
        jButtonNuevo = new javax.swing.JButton();
        jButtonModificar = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "PERMISOS", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 12), new java.awt.Color(94, 148, 189))); // NOI18N

        jLabel5.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel5.setText("Permisos Asignados");

        jListAsignados.setFont(new java.awt.Font("Verdana", 1, 10));
        jListAsignados.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jListAsignados.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jListAsignadosValueChanged(evt);
            }
        });

        jButtonDisponibleAsignado.setFont(new java.awt.Font("Verdana", 1, 5));
        jButtonDisponibleAsignado.setForeground(new java.awt.Color(94, 148, 189));
        jButtonDisponibleAsignado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Mover_normal.gif"))); // NOI18N
        jButtonDisponibleAsignado.setToolTipText("Asignar permiso al usuario");
        jButtonDisponibleAsignado.setBorderPainted(false);
        jButtonDisponibleAsignado.setContentAreaFilled(false);
        jButtonDisponibleAsignado.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Mover_deshabilitado.gif"))); // NOI18N
        jButtonDisponibleAsignado.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Mover_presionado.gif"))); // NOI18N
        jButtonDisponibleAsignado.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Mover_mouse.gif"))); // NOI18N
        jButtonDisponibleAsignado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDisponibleAsignadoActionPerformed(evt);
            }
        });

        jListDisponibles.setFont(new java.awt.Font("Verdana", 1, 10));
        jListDisponibles.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jListDisponibles.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jListDisponiblesValueChanged(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel6.setText("Permisos Disponibles");

        jButtonAceptar.setFont(new java.awt.Font("Verdana", 1, 10));
        jButtonAceptar.setForeground(new java.awt.Color(94, 148, 189));
        jButtonAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Aceptar_normal.gif"))); // NOI18N
        jButtonAceptar.setToolTipText("Almacenar los cambios");
        jButtonAceptar.setBorderPainted(false);
        jButtonAceptar.setContentAreaFilled(false);
        jButtonAceptar.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Aceptar_deshabilitado.gif"))); // NOI18N
        jButtonAceptar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Aceptar_presionado.gif"))); // NOI18N
        jButtonAceptar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Aceptar_mouse.gif"))); // NOI18N
        jButtonAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAceptarActionPerformed(evt);
            }
        });

        jButtonAsignadoDisponible.setFont(new java.awt.Font("Verdana", 1, 5));
        jButtonAsignadoDisponible.setForeground(new java.awt.Color(94, 148, 189));
        jButtonAsignadoDisponible.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/MoverIzq_normal.gif"))); // NOI18N
        jButtonAsignadoDisponible.setToolTipText("Quitar Permiso al usuario");
        jButtonAsignadoDisponible.setBorderPainted(false);
        jButtonAsignadoDisponible.setContentAreaFilled(false);
        jButtonAsignadoDisponible.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/MoverIzq_deshabilitado.gif"))); // NOI18N
        jButtonAsignadoDisponible.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/MoverIzq_presionado.gif"))); // NOI18N
        jButtonAsignadoDisponible.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/MoverIzq_mouse.gif"))); // NOI18N
        jButtonAsignadoDisponible.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAsignadoDisponibleActionPerformed(evt);
            }
        });

        jButtonVolver.setFont(new java.awt.Font("Verdana", 1, 10));
        jButtonVolver.setForeground(new java.awt.Color(94, 148, 189));
        jButtonVolver.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_normal.gif"))); // NOI18N
        jButtonVolver.setToolTipText("Volver a la pantalla Principal");
        jButtonVolver.setBorderPainted(false);
        jButtonVolver.setContentAreaFilled(false);
        jButtonVolver.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_deshabilitado.gif"))); // NOI18N
        jButtonVolver.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_presionado.gif"))); // NOI18N
        jButtonVolver.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_mouse.gif"))); // NOI18N
        jButtonVolver.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVolverActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(174, 174, 174)
                .addComponent(jButtonAceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addComponent(jButtonVolver, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(208, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jListDisponibles, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(35, 35, 35)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButtonDisponibleAsignado, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonAsignadoDisponible, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jListAsignados, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(87, 87, 87))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel5))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(81, 81, 81)
                        .addComponent(jButtonDisponibleAsignado, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonAsignadoDisponible, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jListDisponibles, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jListAsignados, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 54, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButtonVolver, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonAceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "USUARIO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 12), new java.awt.Color(94, 148, 189))); // NOI18N

        jTextNombre.setFont(new java.awt.Font("Verdana", 1, 10));
        jTextNombre.setForeground(new java.awt.Color(94, 148, 189));
        jTextNombre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextNombreActionPerformed(evt);
            }
        });
        jTextNombre.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextNombreKeyReleased(evt);
            }
        });

        jLabelNombre.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabelNombre.setText("Nombre De Usuario:");

        jLabelPass.setFont(new java.awt.Font("Verdana", 0, 10)); // NOI18N
        jLabelPass.setText("Contraseña:");

        jLabelNom.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabelNom.setText("Nombre:");

        jLabelApe.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabelApe.setText("Apellido:");

        jTextNom.setFont(new java.awt.Font("Verdana", 1, 10));
        jTextNom.setForeground(new java.awt.Color(94, 148, 189));
        jTextNom.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextNomKeyReleased(evt);
            }
        });

        jTextApe.setFont(new java.awt.Font("Verdana", 1, 10));
        jTextApe.setForeground(new java.awt.Color(94, 148, 189));
        jTextApe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextApeActionPerformed(evt);
            }
        });
        jTextApe.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextApeKeyReleased(evt);
            }
        });

        jButtonGuardar.setFont(new java.awt.Font("Verdana", 1, 10));
        jButtonGuardar.setForeground(new java.awt.Color(94, 148, 189));
        jButtonGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Modificar_normal.gif"))); // NOI18N
        jButtonGuardar.setToolTipText("Modificar la contraseña del usuario");
        jButtonGuardar.setBorderPainted(false);
        jButtonGuardar.setContentAreaFilled(false);
        jButtonGuardar.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Modificar_deshabilitado.gif"))); // NOI18N
        jButtonGuardar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Modificar_presionado.gif"))); // NOI18N
        jButtonGuardar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Modificar_mouse.gif"))); // NOI18N
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        jButtonEliminar.setFont(new java.awt.Font("Verdana", 1, 10));
        jButtonEliminar.setForeground(new java.awt.Color(94, 148, 189));
        jButtonEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Eliminar_normal.gif"))); // NOI18N
        jButtonEliminar.setToolTipText("Eliminar al usuario");
        jButtonEliminar.setBorderPainted(false);
        jButtonEliminar.setContentAreaFilled(false);
        jButtonEliminar.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Eliminar_deshabilitado.gif"))); // NOI18N
        jButtonEliminar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Eliminar_presionado.gif"))); // NOI18N
        jButtonEliminar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Eliminar_mouse.gif"))); // NOI18N
        jButtonEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEliminarActionPerformed(evt);
            }
        });

        jComboUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboUsuariosActionPerformed(evt);
            }
        });

        jLabelSelecion.setFont(new java.awt.Font("Monotype Corsiva", 1, 18));
        jLabelSelecion.setForeground(new java.awt.Color(94, 148, 189));
        jLabelSelecion.setText("Seleccionar Usuario");

        jTextPass.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextPassKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(198, 198, 198)
                        .addComponent(jLabelSelecion)
                        .addGap(18, 18, 18)
                        .addComponent(jComboUsuarios, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabelNombre)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabelApe)
                                .addComponent(jLabelNom))
                            .addComponent(jLabelPass))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jTextPass, 0, 0, Short.MAX_VALUE)
                                    .addComponent(jTextNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jTextNom)
                            .addComponent(jTextApe))
                        .addGap(83, 83, 83)
                        .addComponent(jButtonEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelSelecion)
                    .addComponent(jComboUsuarios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNombre)
                    .addComponent(jTextNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelPass))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNom)
                    .addComponent(jTextNom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelApe)
                    .addComponent(jTextApe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(96, 96, 96))
        );

        jButtonNuevo.setFont(new java.awt.Font("Verdana", 1, 10));
        jButtonNuevo.setForeground(new java.awt.Color(94, 148, 189));
        jButtonNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Nuevo_normal.gif"))); // NOI18N
        jButtonNuevo.setToolTipText("Crear un nuevo usuario");
        jButtonNuevo.setBorderPainted(false);
        jButtonNuevo.setContentAreaFilled(false);
        jButtonNuevo.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Nuevo_deshabilitado.gif"))); // NOI18N
        jButtonNuevo.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Nuevo_presionado.gif"))); // NOI18N
        jButtonNuevo.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Nuevo_mouse.gif"))); // NOI18N
        jButtonNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNuevoActionPerformed(evt);
            }
        });

        jButtonModificar.setFont(new java.awt.Font("Verdana", 1, 10));
        jButtonModificar.setForeground(new java.awt.Color(94, 148, 189));
        jButtonModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Modificar_normal.gif"))); // NOI18N
        jButtonModificar.setToolTipText("Modificar usuario existente");
        jButtonModificar.setBorderPainted(false);
        jButtonModificar.setContentAreaFilled(false);
        jButtonModificar.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Modificar_deshabilitado.gif"))); // NOI18N
        jButtonModificar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Modificar_presionado.gif"))); // NOI18N
        jButtonModificar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Modificar_mouse.gif"))); // NOI18N
        jButtonModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonModificarActionPerformed(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Monotype Corsiva", 1, 24));
        jLabel8.setForeground(new java.awt.Color(94, 148, 189));
        jLabel8.setText("Seleccionar una opción: ");

        jLabel1.setFont(new java.awt.Font("Monotype Corsiva", 1, 24));
        jLabel1.setForeground(new java.awt.Color(94, 148, 189));
        jLabel1.setText(" USUARIO");

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/logo_GTV4.gif"))); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(121, 121, 121)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(70, 70, 70)
                                .addComponent(jLabel1))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jButtonNuevo, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonModificar, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(153, 153, 153)
                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(864, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(10, 10, 10)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButtonNuevo, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonModificar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel2))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(705, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(368, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    private void limpiarListas(){
        v.removeAllElements();
        jListDisponibles.setListData(v);
        asignados.removeAllElements();
        jListAsignados.setListData(asignados);
    }
    
    public void cargarPermisosGenerales(){
    
    for (int i=0; i<abmuc.ObtenerPermisos().size();i++)
        v.addElement(abmuc.ObtenerPermisos().get(i));
    jListDisponibles.setListData(v);
}
    
    
    /**carga los permisos de los usuarios en listas,en una los asingados y en otra los pendientes*/
    public void cargarPermisos(){
        for (int i=0;i<usuario.getPermiso().size();i++)
            asignados.add(usuario.getPermiso().get(i));
         
        for (int j=0;j<abmuc.ObtenerPermisos().size();j++)
           {  
              int flag=0;
              for (int k=0;k<usuario.getPermiso().size();k++)
                if (abmuc.ObtenerPermisos().get(j).getDescripcion().equals(usuario.getPermiso().get(k).getDescripcion()))
                    flag=1;
              if (flag==0) v.add(abmuc.ObtenerPermisos().get(j));
              
           }
                
    
        jListDisponibles.setListData(v);
        jListAsignados.setListData(asignados);
    }
private void jListAsignadosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListAsignadosValueChanged
//mostrarDetalle(jListAsignados,this.ventana);
}//GEN-LAST:event_jListAsignadosValueChanged
/*paso de permisos disponibles a asignados*/
private void jButtonDisponibleAsignadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDisponibleAsignadoActionPerformed
if(jListDisponibles.isSelectionEmpty() == false){ 
   asignados.addElement(jListDisponibles.getSelectedValue());
    jListAsignados.setListData(asignados);
    v.remove(jListDisponibles.getSelectedValue());
    jListDisponibles.setListData(v);          
    
    //Almacena los cambios!!
 
 }
}//GEN-LAST:event_jButtonDisponibleAsignadoActionPerformed

private void jListDisponiblesValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListDisponiblesValueChanged
//mostrarDetalle(jListDisponibles,this.ventana);
}//GEN-LAST:event_jListDisponiblesValueChanged
/** guardo la modificacion de permisos de usuario*/
private void jButtonAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAceptarActionPerformed

    if(this.estado.compareTo("Modificar") == 0){

                boolean resultado = false;
            try{ 
                if (abmuc.validarNombreUsuario(jTextNombre.getText().toString())&& abmuc.validarPsw(jTextPass.getText().toString())&&abmuc.validarNombre(jTextNom.getText().toString())&&abmuc.validarApellido(jTextApe.getText().toString())&&abmuc.validarPermisos(asignados))
                {
                     ArrayList<Permiso> permiso =new ArrayList<Permiso>();
                     usuario.setNombreUsuario(jTextNombre.getText().toString());
                     usuario.setPassword(jTextPass.getText().toString());
                     usuario.setNombre(jTextNom.getText().toString());
                     usuario.setApellido(jTextApe.getText().toString());
                        for (int i=0; i<asignados.size(); i++)
                             permiso.add((Permiso)asignados.get(i));
                     usuario.setPermiso(permiso);
                     abmuc.modificarUsuario(usuario);
                     JOptionPane.showMessageDialog(new JFrame(), "Usuario modificado correctamente"," ", JOptionPane.INFORMATION_MESSAGE);
                     deshabilitarComponentesModificacion();
                     jButtonNuevo.setEnabled(true);
                     jButtonModificar.setEnabled(true);
                }
               }
                    catch (Exception e){
                     //   JOptionPane.showMessageDialog(new JFrame(), "Error, no se pudo modificar"," ", JOptionPane.INFORMATION_MESSAGE);
                    }
}//GEN-LAST:event_jButtonAceptarActionPerformed
    
    if(this.estado.compareTo("Nuevo") == 0){
    boolean resultado=false;
    boolean valido = false;
try{ 
    if (abmuc.validarNombreUsuario(jTextNombre.getText().toString())&& abmuc.validarPsw(jTextPass.getText().toString())&&abmuc.validarNombre(jTextNom.getText().toString())&&abmuc.validarApellido(jTextApe.getText().toString())&&abmuc.validarPermisos(asignados))
    {
        ArrayList<Permiso> permiso =new ArrayList<Permiso>();
        usuario.setNombreUsuario(jTextNombre.getText().toString());
        usuario.setPassword(jTextPass.getText().toString());
        usuario.setNombre(jTextNom.getText().toString());
        usuario.setApellido(jTextApe.getText().toString());
        for (int i=0; i<asignados.size(); i++)
           permiso.add((Permiso)asignados.get(i));
        usuario.setPermiso(permiso);

        resultado=abmuc.IngresarUsuario(usuario);
        valido = true;
        
      }

    if (resultado==true){
              JOptionPane.showMessageDialog(new JFrame(), "Usuario creado correctamente"," ", JOptionPane.INFORMATION_MESSAGE);
             deshabilitarComponentesAlta();
             jButtonNuevo.setEnabled(true);
             jButtonModificar.setEnabled(true);
            
          }else{
            if (valido){ 
            JOptionPane.showMessageDialog(new JFrame(), "Error: el usuario ya existe"," ", JOptionPane.INFORMATION_MESSAGE);
             deshabilitarComponentesAlta();
             jButtonNuevo.setEnabled(true);
             jButtonModificar.setEnabled(true);
            }
          }
              
       
    
       }
        catch (Exception e){
           e.printStackTrace();
       
        }
    
    
    }



}                                        
/** paso de permisos asignados a disponibles*/
private void jButtonAsignadoDisponibleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAsignadoDisponibleActionPerformed
        if(jListAsignados.isSelectionEmpty() == false){ 
              v.addElement(jListAsignados.getSelectedValue());
        jListDisponibles.setListData(v);
        asignados.remove(jListAsignados.getSelectedValue());
        jListAsignados.setListData(asignados);
    
    }  
}//GEN-LAST:event_jButtonAsignadoDisponibleActionPerformed
/** boton volver*/
private void jButtonVolverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVolverActionPerformed
    
    Object[] opciones ={"Si","No"};
    
    if (estado.compareTo("Nuevo") == 0 && jButtonAceptar.isEnabled()){
       if(jTextNombre.getText().compareTo("") != 0 ||
            jTextPass.getText().compareTo("") != 0 ||
            jTextNom.getText().compareTo("") != 0 ||
            jTextApe.getText().compareTo("") !=0 ||
            asignados.isEmpty() == false){

                try{
                  int selec = JOptionPane.showOptionDialog(new JFrame(), "Si vuelve perderá los cambios ¿Está seguro?","Atención!",JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,null, opciones, null);
                  if(selec == 0){
                       ppal.cargarFormulario();
                       this.dispose();
                  }
                }catch (Exception e){}
        }else{
        ppal.cargarFormulario();
        this.dispose();
    }
            
       
    }else{
        ppal.cargarFormulario();
        this.dispose();
    }
        
     
  
}//GEN-LAST:event_jButtonVolverActionPerformed

private void jTextApeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextApeActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextApeActionPerformed
/**seleccion de usuario del combo*/
private void jComboUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboUsuariosActionPerformed
        
        
        v.removeAllElements();
        asignados.removeAllElements();
        usuario=new Usuario();
        try{
            usuario=(Usuario)jComboUsuarios.getSelectedItem();
            cargarPermisos();
            this.jTextNombre.setText(usuario.getNombreUsuario().toString());
            this.jTextNombre.setEditable(false);
            this.jTextPass.setText(usuario.getPassword().toString());
            this.jTextNom.setText(usuario.getNombre().toString());
            this.jTextNom.setEditable(false);
            this.jTextApe.setText(usuario.getApellido().toString());
            this.jTextApe.setEditable(false); 
            this.jTextPass.setEditable(true);
        
        }catch (Exception e){
            
        }
        
        
    
}//GEN-LAST:event_jComboUsuariosActionPerformed
/**modificación de contraseña*/
private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed
    CambiaPass gForm = new CambiaPass(this, true, jTextNombre.getText());
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;
    gForm.setLocation(screenWidth / 4, screenHeight / 4);
    gForm.setVisible(true);
}//GEN-LAST:event_jButtonGuardarActionPerformed
/*eliminar usuario*/
private void jButtonEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEliminarActionPerformed
     
    Object[] opciones ={"Si","No"};
    
    
        try{
          int selec = JOptionPane.showOptionDialog(new JFrame(), "¿Está seguro de eliminar el usuario?","Atención!",JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,null, opciones, null);
          if(selec == 0){
                 abmuc.eliminarUsuario(usuario);
                 JOptionPane.showMessageDialog(new JFrame(), "Usuario eliminado correctamente"," ", JOptionPane.INFORMATION_MESSAGE);
                 jButtonEliminar.setEnabled(false);
                 this.jComboUsuarios.setEnabled(false);
                 jTextPass.setEditable(false);
                 this.jButtonGuardar.setEnabled(false);
                 jButtonModificar.setEnabled(true);
                 deshabilitarComponentesModificacion();
          }else
              this.dispose();
                 

        } catch(Exception e){
            
        }
     
     

}//GEN-LAST:event_jButtonEliminarActionPerformed

private void jTextNombreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextNombreActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextNombreActionPerformed

private void jButtonNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNuevoActionPerformed
     paraCrear();
     limpiarListas(); 
     cargarPermisosGenerales();
     usuario=new Usuario();
     this.estado="Nuevo";
     jTextNombre.grabFocus();
    jTextNombre.setCaretPosition(0);
     
}//GEN-LAST:event_jButtonNuevoActionPerformed

private void jButtonModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModificarActionPerformed
    if (abmuc.obtenerUsuarios().size() > 0){
        paraModificar();
        limpiarListas();
        cargarComboUsuarios();
        this.estado="Modificar";
    }else
        JOptionPane.showMessageDialog(new JFrame(), "No hay usuarios cargados en el sistema"," ", JOptionPane.INFORMATION_MESSAGE);
  
}//GEN-LAST:event_jButtonModificarActionPerformed

private void jTextNombreKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextNombreKeyReleased
if(jTextNombre.getText().length()>15){
            JOptionPane.showMessageDialog(new JFrame(), "La longitud máxima es de 15 caracteres"," ", JOptionPane.INFORMATION_MESSAGE);
            jTextNombre.setText(jTextNombre.getText().substring(0,15));
    }
}//GEN-LAST:event_jTextNombreKeyReleased

private void jTextPassKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextPassKeyReleased
// TODO add your handling code here:
}//GEN-LAST:event_jTextPassKeyReleased

private void jTextNomKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextNomKeyReleased
if(jTextNom.getText().length()>30){
            JOptionPane.showMessageDialog(new JFrame(), "La longitud máxima es de 30 caracteres"," ", JOptionPane.INFORMATION_MESSAGE);
            jTextNom.setText(jTextNom.getText().substring(0,30));
    }
}//GEN-LAST:event_jTextNomKeyReleased

private void jTextApeKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextApeKeyReleased
if(jTextApe.getText().length()>30){
            JOptionPane.showMessageDialog(new JFrame(), "La longitud máxima es de 30 caracteres"," ", JOptionPane.INFORMATION_MESSAGE);
            jTextApe.setText(jTextApe.getText().substring(0,30));
    }
}//GEN-LAST:event_jTextApeKeyReleased

    private void paraModificar(){ 
    
  
    jButtonNuevo.setEnabled(true);
    jButtonModificar.setEnabled(false);
    jLabelSelecion.setVisible(true);
    jComboUsuarios.setEnabled(true);
    jComboUsuarios.setVisible(true);
    jButtonEliminar.setVisible(true);
    jButtonEliminar.setEnabled(true);
    jButtonGuardar.setVisible(true);
    jButtonGuardar.setEnabled(true);
    
    jTextNombre.setText("");
    jTextPass.setText("");
    jTextNom.setText("");
    jTextApe.setText("");
    
    jButtonAceptar.setEnabled(true);
    jButtonAceptar.setText("MODIFICAR");
    
    estadoPanelPermisos(true);
    

    }


    private void paraCrear(){
        estadoPanelUsuario(true);
        estadoPanelPermisos(true);
        jButtonAceptar.setEnabled(true);
        jButtonAceptar.setText("CREAR");
        jButtonGuardar.setEnabled(false);
        jButtonEliminar.setEnabled(false);
        jButtonNuevo.setEnabled(false);
        jButtonModificar.setEnabled(true);
        this.jTextNombre.setText("");
        this.jTextPass.setText("");
        this.jTextNom.setText("");
        this.jTextApe.setText("");
        jLabelSelecion.setVisible(false);
        jComboUsuarios.setVisible(false);
        jButtonEliminar.setVisible(false);
        jButtonGuardar.setVisible(false);
          
    }
    

  
    
    /**deshabilito componentes*/
public void deshabilitarComponentesModificacion(){
        this.jListAsignados.setEnabled(false);
        this.jListDisponibles.setEnabled(false);
        this.jButtonAsignadoDisponible.setEnabled(false);
        this.jButtonDisponibleAsignado.setEnabled(false);
        this.jButtonAceptar.setEnabled(false);
}


public void deshabilitarComponentesAlta(){
    this.jTextNombre.setEnabled(false);
    this.jTextPass.setEnabled(false);
    this.jTextNom.setEnabled(false);
    this.jTextApe.setEnabled(false);
    this.jListAsignados.setEnabled(false);
    this.jListDisponibles.setEnabled(false);
    this.jButtonAceptar.setEnabled(false);
    this.jButtonAsignadoDisponible.setEnabled(false);
    this.jButtonDisponibleAsignado.setEnabled(false);
    
}
    

public void setPpal(PpalForm p){
        this.ppal=p;
}

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonAceptar;
    private javax.swing.JButton jButtonAsignadoDisponible;
    private javax.swing.JButton jButtonDisponibleAsignado;
    private javax.swing.JButton jButtonEliminar;
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JButton jButtonModificar;
    private javax.swing.JButton jButtonNuevo;
    private javax.swing.JButton jButtonVolver;
    private javax.swing.JComboBox jComboUsuarios;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabelApe;
    private javax.swing.JLabel jLabelNom;
    private javax.swing.JLabel jLabelNombre;
    private javax.swing.JLabel jLabelPass;
    private javax.swing.JLabel jLabelSelecion;
    private javax.swing.JList jListAsignados;
    private javax.swing.JList jListDisponibles;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JTextField jTextApe;
    private javax.swing.JTextField jTextNom;
    private javax.swing.JTextField jTextNombre;
    private javax.swing.JPasswordField jTextPass;
    // End of variables declaration//GEN-END:variables

}
